import time
from seleniumwire import undetected_chromedriver as uc_wire
from seleniumwire import webdriver  # 注意导入的是seleniumwire
import undetected_chromedriver as uc
# 代理配置
from undetected_chromedriver import ChromeOptions

username = 'd2231274096'
password = 'ela9v3e9'

proxy_options = {
    'proxy': {
        'http': f'http://{username}:{password}@116.208.208.151:23261',
        'https': f'https://{username}:{password}@116.208.208.151:23261',
        'no_proxy': 'localhost,127.0.0.1',
        'verify_ssl': False
    }
}




# 创建浏览器实例
options = uc.ChromeOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
driver_path = r'C:\Program Files\Google\Chrome\Application\chromedriver.exe'

# driver = uc.Chrome(driver_executable_path=driver_path,seleniumwire_options=proxy_options,options=options)
driver = uc_wire.Chrome(
    driver_executable_path=driver_path,
    options=options,
    seleniumwire_options=proxy_options
)
# driver = uc.Chrome(
#     driver_executable_path=driver_path,
#     seleniumwire_options=proxy_options,
#     options=options
# )
time.sleep(2)
driver.get("http://icanhazip.com/")
time.sleep(10)
print("当前IP:", driver.page_source)
driver.quit()
